﻿// AddGuest.cpp: 实现文件
//

#include "pch.h"
#include "MFCApplication1.h"
#include "AddGuest.h"
#include "afxdialogex.h"
//add
#include "mainClass.h"
#include<iostream>
#include <fstream>
#include <sstream>
#include<string>
using namespace std;
// AddGuest 对话框

IMPLEMENT_DYNAMIC(AddGuest, CDialogEx)

AddGuest::AddGuest(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_DIALOG_addGuest, pParent)
{
#ifndef _WIN32_WCE
	EnableActiveAccessibility();
#endif

}

AddGuest::~AddGuest()
{
}

void AddGuest::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	//  DDX_Control(pDX, IDC_EDIT1, g_edit1);
	DDX_Control(pDX, IDC_EDIT1, g_edit1);
}


BEGIN_MESSAGE_MAP(AddGuest, CDialogEx)
	ON_BN_CLICKED(IDC_BUTTON1, &AddGuest::OnBnClickedButton1)
	ON_BN_CLICKED(IDCANCEL, &AddGuest::OnBnClickedCancel)
END_MESSAGE_MAP()


// AddGuest 消息处理程序





void AddGuest::OnBnClickedButton1()
{
	
	CString cstr1,cstr2,cstr3,cstr4,cstr5,cstr6;
	GetDlgItem(IDC_EDIT1)->GetWindowText(cstr1);
	GetDlgItem(IDC_EDIT2)->GetWindowText(cstr2);
	GetDlgItem(IDC_EDIT3)->GetWindowText(cstr3);
	GetDlgItem(IDC_EDIT4)->GetWindowText(cstr4);
	GetDlgItem(IDC_EDIT5)->GetWindowText(cstr5);
	GetDlgItem(IDC_EDIT6)->GetWindowText(cstr6);
	//CString -> string
	string str1(CW2A(cstr1.GetString()));
	string str2(CW2A(cstr2.GetString()));
	string str3(CW2A(cstr3.GetString()));
	string str4(CW2A(cstr4.GetString()));
	string str5(CW2A(cstr5.GetString()));
	string str6(CW2A(cstr6.GetString()));

	ofstream os("Guest.dat", ios_base::binary | ios_base::app);
	Guest g(str1,str2,str3,str4,str5,str6);	//string -> double (please view mainClass.h)
	os << g<<' ';
	os.close();
	CDialogEx::OnOK();
}


void AddGuest::OnBnClickedCancel()
{
	// TODO: 在此添加控件通知处理程序代码
	CDialogEx::OnCancel();
}
